//
//  ArtGalleryCell_first.m
//  jingdongfang
//
//  Created by MTiMac01 on 2017/8/18.
//  Copyright © 2017年 LJL. All rights reserved.
//

#import "ArtGalleryCell_first.h"
#import "HomeViewArtGalleryVC.h"
#import "IGCommunityDetailVC.h"
@interface ArtGalleryCell_first ()
{
    UIImageView *backImg;
    UIButton *backBtn;
    UIButton *playBtn;
}

@end

@implementation ArtGalleryCell_first

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self loadUI];
    }
    return self;
}
- (void)loadUI
{
    backImg = [[UIImageView alloc] initWithFrame:CGRectZero];
    backImg.contentMode = UIViewContentModeScaleAspectFill;
    backImg.backgroundColor = [UIColor c6Color];
    backImg.clipsToBounds = YES;
    [self.contentView addSubview:backImg];
    
    backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setImage:[UIImage imageNamed:@"home_back"] forState:UIControlStateNormal];
    [backBtn setImage:[UIImage imageNamed:@"home_back"] forState:UIControlStateHighlighted];
    [backBtn addTarget:self action:@selector(backBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:backBtn];

    playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    playBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
    [playBtn setImageEdgeInsets:UIEdgeInsetsZero];
    [playBtn setImage:[UIImage imageNamed:@"home_play"] forState:UIControlStateNormal];
    [playBtn setImage:[UIImage imageNamed:@"home_play"] forState:UIControlStateHighlighted];
    [playBtn addTarget:self action:@selector(playBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:playBtn];
    playBtn.hidden = YES;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [backImg sd_setImageWithURL:[NSURL URLWithString:self.imageUrl]];
    backImg.frame = CGRectMake(0, 0, self.width, self.height);
    backBtn.frame = CGRectMake(10, SafeTopMagin + 10, 40, 40);
    playBtn.frame = CGRectMake(self.width - 55, self.height - 55, 40, 40);
}

- (void)backBtnClick
{
    [UIViewController ig_popViewController:[HomeViewArtGalleryVC class]];
}

- (void)playBtnClick
{
//    IGCommunityDetailVC *vc = [[IGCommunityDetailVC alloc] initWithCid:_cid];
//    [UIViewController ig_pushViewController:vc animated:YES];
}

- (void)awakeFromNib
{
    [super awakeFromNib];
}

@end
